Skip to content

feat!: transpile SFC scripts and templates with petrea - #60

Open
Teages wants to merge 7 commits into
mainfrom
feat/oxidase
Open

Teages wants to merge 7 commits into
mainfrom
feat/oxidase

Conversation

@Teages

@Teages Teages commented May 30, 2025 •

Copy link
Copy Markdown
Collaborator

Use petrea to transpile TypeScript script or snappets.

Performance

test with Nuxt UI:

Scope 0.2.5 (baseline) PR build (62d2080) Δ time Improvement
Full build, no dts (pnpm build) 1.51 s 1.37 s −134 ms ~9% faster
Vue loader only (isolated, per-file transpilation of 189 SFCs) 158.9 ms (0.84 ms/file) 77.4 ms (0.41 ms/file) −81.5 ms ~51% faster (2.05×)

Breaking changes

  • mkdist's esbuild option is no longer applied to .vue script blocks, include define
  • only support erasable syntax and enum

@pkg-pr-new

pkg-pr-new Bot commented May 30, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt-contrib/vue-sfc-transformer@60

commit: 9ff0b98

@pi0

pi0 commented May 30, 2025 •

Copy link
Copy Markdown
Member

Intresting. Have you comparared oxidase with oxc-transform? The former is more actively maintained and is from original author. /cc @Boshen

@Teages

Teages commented May 30, 2025 •

Copy link
Copy Markdown
Collaborator Author

Intresting. Have you comparared oxidase with oxc-transform? The former is more actively maintained and is from original author. /cc @Boshen

Yes, maintainer activity is one of my primary considerations when choosing a replacement.

Our use case is quite special: we can’t provide sufficient context to transformers, so they often inadvertently modify our code. For example, even replacing quotes can cause issues. We need to avoid any optimizations introduced by transformers entirely.

oxidase fits perfectly—it strips TypeScript syntax quickly and effectively without unnecessary transformations. It also keep the code position and save us additional work on sourcemap.

Given these reasons, oxidase is an ideal solution for us.

@Teages
Teages marked this pull request as ready for review May 30, 2025 16:22
@Teages
Teages requested a review from danielroe May 30, 2025 16:22
@Boshen

Boshen commented May 31, 2025

Copy link
Copy Markdown

oxidase was an experiment. It is not maintained. The author now works with us on another project.

@Teages

Teages commented May 31, 2025

Copy link
Copy Markdown
Collaborator Author

oxidase was an experiment. It is not maintained. The author now works with us on another project.

@Boshen Is the another project some kind of transpiler? I know our use case is niche, but it's pity that oxidase is no longer maintained.

I tried oxc-parser, but unfortunately the AST it provided lost a lot of keyword position information. (e.g. readonly, public, private and ?)

If we want to strip these keywords accurately, we need to call TypeScript's scanner, which is not much different from ts-blank-space (We also need an additional oxc-parser dependency)

@danielroe What do you think about switching to ts-blank-space?

@Teages Teages left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I make a lib with oxc-parser for transpiling https://github.com/Teages/oxc-blank-space

It passed all test from ts-blank-space and enum test from oxidase (ts-blank-space does not support enum).

I haven't done any bench yet, because the performance improve may be not obvious before we migrate to rust. But I think this would be a good start for switching to "transpile".

@Teages Teages changed the title feat: replace esbuild with oxidase feat: transpile typescript code Instead of transform Jun 2, 2025
@Teages Teages changed the title feat: transpile typescript code Instead of transform feat: transpile typescript code instead of transform Jun 2, 2025
@Teages
Teages marked this pull request as draft June 6, 2025 18:13
@Teages
Teages marked this pull request as ready for review September 7, 2026 10:38
@Teages

Teages commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

@teages/oxc-blank-space petrea is now built with rust.

Benchmark on nuxt-ui:

Transpiler Total (best) Total (avg) Speedup (esbuild = 1x)
petrea 0.4.0 6.5 ms 6.7 ms 12.1x
rolldown 1.2.5 14.6 ms 15.2 ms 5.3x
esbuild 0.28.0 78.0 ms 81.3 ms 1.0x

@Teages Teages changed the title feat: transpile typescript code instead of transform feat!: transpile typescript code instead of transform Sep 7, 2026
@Teages Teages changed the title feat!: transpile typescript code instead of transform feat: transpile typescript code instead of transform by default Sep 12, 2026
@Teages
Teages changed the base branch from main to feat/tsx September 13, 2026 12:52
@Teages
Teages added this pull request to stack #324 September 13, 2026 12:55
@Teages
Teages marked this pull request as draft September 16, 2026 13:03
@Teages Teages changed the title feat: transpile typescript code instead of transform by default feat!: transpile SFC scripts and templates with petrea Sep 19, 2026
@Teages
Teages marked this pull request as ready for review September 20, 2026 01:35
Base automatically changed from feat/tsx to main October 20, 2026 16:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants